<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

 <ui:composition>
 
 	<ui:insert>
 	
 	</ui:insert>
 
 <script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/componentes/validator/js/Validator.js"></script>
 <script type="text/javascript"> 

 	var jsonOptions = "";

 	
 	var debug = "#{debug}";
 	var submitHandler = "#{submitHandler}";
 	var ignore = "#{ignore}";
 	var invalidHandler = "#{invalidHandler}";
 	var groups = "#{groups}";
 	var onsubmitValidator = "#{onsubmitValidator}";
 	var onfocusout = "#{onfocusout}";
 	var onkeyupValidator = "#{onkeyupValidator}";
 	var focusCleanup = "#{focusCleanup}";
 	var errorPlacement = "#{errorPlacement}";
 	var highlight ="#{highlight}";
 	var unhighlight = "#{unhighlight}";
 	var ignoreTitle = "#{ignoreTitle}";
 	
 	if(debug != ''){

 		jsonOptions = $.extend(jsonOptions,{"debug":debug});
 	 	
 	}

 	<c:if test = "#{not empty submitHandler}">

		jsonOptions = $.extend(jsonOptions,{"submitHandler":#{submitHandler}});
	
 	</c:if>

 	<c:if test="#{not empty ignore}">

		jsonOptions = $.extend(jsonOptions,{"ignore":ignore});
	
 	</c:if>


	<c:if test = "#{not empty invalidHandler}">

		jsonOptions = $.extend(jsonOptions,{"invalidHandler":#{invalidHandler}});

	</c:if>

	if(groups != ''){
	
		jsonOptions = $.extend(jsonOptions,{"groups":groups});
		
	}

	if(onsubmitValidator != ''){
		
		jsonOptions = $.extend(jsonOptions,{"onsubmit":onsubmitValidator});
		
	}

	<c:if test="#{not empty onfocusout}">
		<c:if test ="#{onfocusout eq 'false'}">
			jsonOptions = $.extend(jsonOptions,{"onfocusout":onfocusout});	
		</c:if>
		<c:if test ="#{onfocusout ne 'false'}">
			jsonOptions = $.extend(jsonOptions,{"onfocusout":#{onfocusout}});	
		</c:if>	
	</c:if>
	
	<c:if test="#{not empty onkeyupValidator}">
		<c:if test ="#{onkeyupValidator eq 'false'}">
			jsonOptions = $.extend(jsonOptions,{"onkeyup":onkeyupValidator});	
		</c:if>
		<c:if test ="#{onkeyupValidator ne 'false'}">
			jsonOptions = $.extend(jsonOptions,{"onkeyup":#{onkeyupValidator}});	
		</c:if>	
	</c:if>

	<c:if test="#{not empty onclickValidator}">
		<c:if test ="#{onclickValidator eq 'false'}">
			jsonOptions = $.extend(jsonOptions,{"onclick":onclickValidator});	
		</c:if>
		<c:if test ="#{onclickValidator ne 'false'}">
			jsonOptions = $.extend(jsonOptions,{"onclick":#{onclickValidator}});	
		</c:if>	
	</c:if>
	
	if(focusCleanup != ''){

		jsonOptions = $.extend(jsonOptions,{"focusCleanup":focusCleanup});

	}

 	<c:if test="#{not empty errorPlacement}">

		jsonOptions = $.extend(jsonOptions,{"errorPlacement":#{errorPlacement}});
	
 	</c:if>

	if(highlight != ''){
		
		if(highlight == "true"){
		
			jsonOptions = $.extend(jsonOptions,{

				highlight(element, error){

					$(element).fadeOut(function(){
						
							$(element).fadeIn();
								           
			    	});

				}
			});

		}


	}

	if(unhighlight != ''){
	
		if(unhighlight == "true"){
		
			jsonOptions = $.extend(jsonOptions,{

				unhighlight(element, error){

					$(element).fadeOut(function() {
						
							$(element).fadeIn().addClass('valid');	
								           
			    	});

				}
			});

		} 

	}

	if(ignoreTitle != ''){

		jsonOptions = $.extend(jsonOptions,{"ignoreTitle":ignoreTitle});
		
	}

	<c:if test="#{not empty customFunctionValidation}">
	
		jsonOptions = $.extend(jsonOptions,{"customFunctionValidation":#{customFunctionValidation}}); 	
		
		
	</c:if>


	var stringDivErro = "";
	
	if(!($("#msgErro").length)){
		
		stringDivErro = '<div id="msgErro"></div>';
		$("#" + "#{form}").prepend(stringDivErro);
		$("#msgErro").hide();
		
	}

	console.log(jsonOptions);

	validator.construirValidador("#" + "#{form}", jsonOptions);



 </script>
  
 </ui:composition>
   
</html>